
package com.heitian.ssm.service.impl;

import com.heitian.ssm.dao.HelpEntityMapper;
import com.heitian.ssm.model.HelpEntity;
import com.heitian.ssm.service.HelpService;
import com.heitian.ssm.utils.FastJsonUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * User: mishuai
 * Date: 2018-04-23
 * Time: 15:12
 * Des:
 */
@Service("helpService")
@Transactional(rollbackFor = Exception.class)
public class HelpServiceImpl implements HelpService{
    private Logger log = Logger.getLogger(HelpServiceImpl.class);
    @Resource
    private HelpEntityMapper helpEntityMapper;

    public int insertContent(HelpEntity helpEntity) {
        log.info("入参实体"+ FastJsonUtils.toJSONString(helpEntity));
        if(helpEntity ==null){
            return 0;
        }
        int i=helpEntityMapper.insertSelective(helpEntity);
        log.info("出参信息"+i);
        return i;
    }

    public int updateContent(HelpEntity helpEntity) {
        return 0;
    }

    public HelpEntity selectContent() {
        log.info("查询使用帮助信息");
        HelpEntity helpEntity=null;
        try{
            helpEntity= helpEntityMapper.selectByPrimaryKey();
        }catch (Exception e){
           log.info(e);
           e.printStackTrace();
        }

        return helpEntity;
    }

    public HelpEntity selectHelp() {
        log.info("查询使用帮助信息");
        HelpEntity helpEntity=null;
        try{
            helpEntity= helpEntityMapper.selectByPrimary();
        }catch (Exception e){
            log.info(e);
            e.printStackTrace();
        }

        return helpEntity;
    }
}
